<template>
  <div>
    <div class="card-table" v-if="types === '流转' ? false : true">
      <el-dialog
        :visible.sync="dialogVisible"
        width="25%"
        center
        :before-close="() => $emit('dialogQuxiao')"
      >
        <div class="header">
          <div
            style="
              margin-left: 11px;
              font-size: 17px;
              color: #22a1ff;
              font-weight: 500;
            "
          >
            {{ types }}工单
          </div>
        </div>
        <div class="main">
          <el-form size="small" ref="form" :model="form" label-width="80px">
            <el-form-item label="工单类型" prop="workOrderType">
              <el-input style="width: 300px" v-model="types" :disabled="true">
              </el-input>
            </el-form-item>

            <el-form-item
              :label="types == '出库' ? '出库数量' : '入库数量'"
              prop="number"
            >
              <el-input
                style="width: 300px"
                v-model="form.number"
                placeholder="请输入数量"
                clearable
              >
              </el-input>
            </el-form-item>
            <el-form-item label="外协地" prop="outside">
              <el-input
                style="width: 300px"
                v-model="form.outside"
                placeholder="请输入外协地"
                clearable
              >
              </el-input>
            </el-form-item>
            <el-form-item label="客户" prop="Customer">
              <el-input
                style="width: 300px"
                v-model="form.Customer"
                placeholder="请输入客户"
                clearable
              >
              </el-input>
            </el-form-item>
            <el-form-item label="批号" prop="lotNumber">
              <el-input
                style="width: 300px"
                v-model="form.lotNumber"
                placeholder="请输入批号"
                clearable
              >
              </el-input>
            </el-form-item>
            <el-form-item label="填写人员" prop="inputPeople">
              <el-input
                style="width: 300px"
                v-model="form.inputPeople"
                placeholder="请输入填写人"
              >
              </el-input>
            </el-form-item>

            <el-form-item label="备注" prop="remark">
              <el-input
                type="textarea"
                :autosize="{ minRows: 2, maxRows: 4 }"
                style="width: 300px"
                v-model="form.remark"
              >
              </el-input>
            </el-form-item>
          </el-form>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="$emit('dialogQuxiao'), (form = {})"
            >取 消</el-button
          >
          <el-button type="primary" @click="resetForm">确 定</el-button>
        </span>
      </el-dialog>
    </div>
    <div class="card-table" v-if="types === '流转' ? true : false">
      <el-dialog
        :visible.sync="dialogVisible"
        width="25%"
        center
        :before-close="() => $emit('dialogQuxiao')"
      >
        <div class="header">
          <div
            style="
              margin-left: 11px;
              font-size: 17px;
              color: #22a1ff;
              font-weight: 500;
            "
          >
            {{ types }}工单
          </div>
        </div>
        <div class="main">
          <el-form size="small" ref="form" :model="form" label-width="80px">
            <el-form-item label="工单类型" prop="workOrderType">
              <el-input style="width: 300px" v-model="types" :disabled="true">
              </el-input>
            </el-form-item>

            <el-form-item
              :label="types == '出库' ? '出库数量' : '入库数量'"
              prop="number"
            >
              <el-input
                style="width: 300px"
                v-model="form.number"
                placeholder="请输入数量"
                clearable
              >
              </el-input>
            </el-form-item>
            <el-form-item label="外协地" prop="outside">
              <el-input
                style="width: 300px"
                v-model="form.outside"
                placeholder="请输入外协地"
                clearable
              >
              </el-input>
            </el-form-item>
            <el-form-item label="客户" prop="Customer">
              <el-input
                style="width: 300px"
                v-model="form.Customer"
                placeholder="请输入客户"
                clearable
              >
              </el-input>
            </el-form-item>
            <el-form-item label="批号" prop="lotNumber">
              <el-input
                style="width: 300px"
                v-model="form.lotNumber"
                placeholder="请输入批号"
                clearable
              >
              </el-input>
            </el-form-item>
            <el-form-item label="填写人员" prop="inputPeople">
              <el-input
                style="width: 300px"
                v-model="form.inputPeople"
                placeholder="请输入填写人"
              >
              </el-input>
            </el-form-item>

            <el-form-item label="备注" prop="remark">
              <el-input
                type="textarea"
                :autosize="{ minRows: 2, maxRows: 4 }"
                style="width: 300px"
                v-model="form.remark"
              >
              </el-input>
            </el-form-item>
          </el-form>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="$emit('dialogQuxiao'), (form = {})"
            >取 消</el-button
          >
          <el-button type="primary" @click="resetForm">确 定</el-button>
        </span>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import { NewLIUZHUANupdate } from "@/api/stock/banlance3.js";

export default {
  data() {
    return {
      types: this.type,
      form: this.row,
      dialogVisible: this.diasbled,
    };
  },
  props: ["type", "row", "diasbled"],
  emits: ["dialogQuxiao"],
  watch: {
    type(n) {
      this.types = n;
      console.log(this.types, 1);
    },
    diasbled(n) {
      this.dialogVisible = n;
    },
    row(n) {
      if (n != 1) this.form = n;
    },
  },

  methods: {
    async resetForm() {
      console.log(this.form, 123);
      this.form.number = parseInt(this.form.number);
      NewLIUZHUANupdate(this.form).then((res) => {
        if (res.data.code === 200) {
          this.$message({
            type: "success",
            message: "修改成功",
          });
        } else {
          this.$message({
            type: "warning",
            message: res.data.message,
          });
        }
        this.form = {};
        this.$emit("dialogQuxiao");
      });
    },
  },
};
</script>

<style  scoped></style>
